export default {
    scrollIntoView (node, parent) {
        const parent_top = node.offsetParent.offsetHeight / 3;
        const node_top = node.offsetTop;

        let offset = 0;

        if (node_top > parent_top) {
            offset = node_top - parent_top;
        }

        console.log('computed', offset);
        this.scrollTo(parent, offset);
    },

    scrollTo (node, offset) {
        let node_top = node.scrollTop;
        node_top += (offset - node_top) * 0.3;

        console.log('scrollTo', node_top);
        if (Math.abs(node_top - offset) < 2) {
            elem.scrollTop = offset;
            return;
        }

        node.scrollTop = node_top;
        setTimeout(this.scrollTo, 40, node, offset);
    }
}
